﻿using System;
using UnityEngine;
namespace LitTools
{
    /// <summary>
    /// 2D碰撞器观察
    /// </summary>
    [DisallowMultipleComponent]
    public class Collider2DObserver : MonoBehaviour
    {
        public event Action<Collision2D> OnCollision2DEnterAct;
        public event Action<Collision2D> OnCollision2DStayAct;
        public event Action<Collision2D> OnCollision2DExitAct;
        private void OnCollisionEnter2D(Collision2D collision)
        {
            OnCollision2DEnterAct?.Invoke(collision);
        }

        private void OnCollisionStay2D(Collision2D collision)
        {
            OnCollision2DStayAct?.Invoke(collision);
        }

        private void OnCollisionExit2D(Collision2D collision)
        {
            OnCollision2DExitAct.Invoke(collision);
        }
    }
}